package table_host;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import adapter.HistortRecordAdapter;
import entity.ContactEntityTest;
import entity.RecordEntity;
import tangyaxin.www.saoerweima.BaseAcitivity;
import tangyaxin.www.saoerweima.R;

/**
 * Created by Administrator on 2016/6/7.
 */
public class HistortActivity extends BaseAcitivity {
    private ListView histortListView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.frament_histort);
        findview();
        initview();
    }

    @Override
    protected void findview() {
        histortListView= (ListView) findViewById(R.id.histort_ListView);
    }

    @Override
    protected void initview() {
        HistortRecordAdapter histortRecordAdapter=new HistortRecordAdapter(HistortActivity.this,getRecortData());
        histortListView.setAdapter(histortRecordAdapter);
        histortListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(HistortActivity.this,"第"+position+"条被点击了",Toast.LENGTH_SHORT).show();
            }
        });
    }

    private List<RecordEntity> getRecortData(){
            List<RecordEntity> recordEntityList=new ArrayList<>();
            ContactEntityTest contactEntityTest =new ContactEntityTest("王麻子","13889564554");
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.TEXT,"测试本本",RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.CONTACT, contactEntityTest,RecordEntity.RECORD_FROM.SCAN));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.URL,"www.baidu.com",RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.CONTACT, contactEntityTest,RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.TEXT,"测试本本",RecordEntity.RECORD_FROM.SCAN));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.URL,"www.baidu.com",RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.TEXT,"测试本本",RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.CONTACT, contactEntityTest,RecordEntity.RECORD_FROM.SCAN));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.URL,"www.baidu.com",RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.CONTACT, contactEntityTest,RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.TEXT,"测试本本",RecordEntity.RECORD_FROM.SCAN));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.URL,"www.baidu.com",RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.TEXT,"测试本本",RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.CONTACT, contactEntityTest,RecordEntity.RECORD_FROM.SCAN));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.URL,"www.baidu.com",RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.CONTACT, contactEntityTest,RecordEntity.RECORD_FROM.MAKE));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.TEXT,"测试本本",RecordEntity.RECORD_FROM.SCAN));
            recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.URL,"www.baidu.com",RecordEntity.RECORD_FROM.MAKE));
            return recordEntityList;
    }
}
